/***********************************
 * 
 * 编写人: 董书承
 * 编写时间: 9_26_2021
 * 编写内容: 确定文件安装位置, 确定必要用户文件或必要文件位置
 *  
/**********************************/ 

# include <iostream>
# include <cstdlib>
# include <unistd.h>
# include <string>
# include "stdIn.hh"

int checkPlace(void);

int checkPlace(void)
{
    char posBuf[80];
    
    getcwd(posBuf, sizeof(posBuf));
    std::string tOrF, instPos;
    std::cout << "请确认安装位置:\n"<< posBuf <<"\n是否正确? [yes] yes/no";
    tOrF = getCommand();
    while(tOrF != "yes" && tOrF != "no")
    {
        std::cout << "输入有误, 请重新输入\n";
        std::cout << "请确认安装位置:\n"<< posBuf <<"\n是否正确? [yes] yes/no";
        tOrF = getCommand();
    }
    while (tOrF == "no")
    {
        std::cout << "请输入安装位置" << std::endl;
        instPos = getCommand();
        tOrF = "Ni";
        while(tOrF != "yes" && tOrF != "no")
        {
            std::cout << "请确认安装位置:\n"<< instPos <<"\n是否正确? [yes] yes/no";
            tOrF = getCommand();
            if (tOrF != "yes" && tOrF != "no")
            {
                std::cout << "输入有误, 请重新输入" << std::endl;
            }
        }
    }
    
    FILE * fp = std::fopen("../../data/installPos", "w");
    fputs(instPos.c_str(), fp);
        

    
    
    
}
